<!--
  ~ This program is part of the OpenLMIS logistics management information system platform software.
  ~ Copyright © 2013 VillageReach
  ~
  ~ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  ~  
  ~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
  ~ You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org. 
  -->

<form auto-save="distribution" object-store="distributions"
      disable-form="{{isFormDisabled()}}">
<div class="row-fluid" ng-class="refrigeratorReading.computeStatus()">
  <div class="span1 status-cell">
    <span class="status-icon"></span>
  </div>
  <div class="span3" ng-bind="refrigeratorReading.refrigerator.serialNumber"></div>
  <div class="span2" ng-bind="refrigeratorReading.refrigerator.brand"></div>
  <div class="span3" ng-bind="refrigeratorReading.refrigerator.model"></div>
  <div class="span3">
    <span class="pull-right">
      <a id="editReading{{$index}}" href="" class="btn btn-small btn-primary"
         ng-click="setEdit(refrigeratorReading.refrigerator.serialNumber, $index)"
         ng-hide="edit[refrigeratorReading.refrigerator.serialNumber]"
         openlmis-message="button.show"></a>
      <input type="button" class="btn btn-small btn-danger" openlmis-message="button.delete"
             ng-click="showDeleteRefrigeratorConfirmationModel(refrigeratorReading.refrigerator.serialNumber)"/>
    </span>
  </div>
</div>

<div ng-show="edit[refrigeratorReading.refrigerator.serialNumber]" class="row-fluid">
  <div class="row-fluid">
    <div class="span1"></div>
    <div class="span11">
      <div class="refrigerator-form clearfix">
        <div class="form-group">
          <div class="form-row clearfix">
            <div class="form-cell">
              <label openlmis-message="label.refrigerator.temperature"></label>
            <span class="position-relative">
              <input type="number" min="-999.9" max="999.9" step="0.1" name="temperature{{$index}}"
                     ng-model="refrigeratorReading.temperature.value" numeric-validator="numericValue,3,1"
                     error-holder="temperatureError{{$index}}" class="right-justified"  ng-trim="false"/>
              <span id="temperatureError{{$index}}" class="rnr-form-error" openlmis-message="error.number.only"
                    style="display: none"></span>
            </span>
              &deg;
              <span openlmis-message="label.celcius.symbol"></span>
              <input id="temperature{{$index}}" type="checkbox"
                     ng-model="refrigeratorReading.temperature.notRecorded"
                     not-recorded/>
              <label class="checkbox-label" for="temperature{{$index}}"
                     openlmis-message="label.not.recorded"></label>

            </div>
          </div>
          <div class="form-row clearfix">
            <div class="form-cell">
              <label openlmis-message="label.problem.last.visit"></label>

              <input type="radio" id="problemSinceLastVisitYes{{ $index }}"
                     name="problemSinceLastVisit{{$index}}"
                     value="Y" ng-model="refrigeratorReading.problemSinceLastTime.value"/>
              <label class="radio-label" for="problemSinceLastVisitYes{{ $index }}"
                     openlmis-message="label.yes"></label>

              <input type="radio" id="problemSinceLastVisitNo{{ $index }}"
                     name="problemSinceLastVisit{{$index}}"
                     value="N"
                     ng-model="refrigeratorReading.problemSinceLastTime.value"/>
              <label class="radio-label" for="problemSinceLastVisitNo{{ $index }}"
                     openlmis-message="label.no"></label>

              <input type="radio" id="problemSinceLastVisitDontKnow{{ $index }}"
                     name="problemSinceLastVisit{{$index}}"
                     value="D"
                     ng-model="refrigeratorReading.problemSinceLastTime.value"/>
              <label class="radio-label" for="problemSinceLastVisitDontKnow{{ $index }}"
                     openlmis-message="label.dont.know"></label>

              <input id="problemSinceLastVisit{{$index}}" type="checkbox"
                     ng-model="refrigeratorReading.problemSinceLastTime.notRecorded"
                     not-recorded ng-click="refrigeratorReading.problems=undefined"/>
              <label class="checkbox-label" for="problemSinceLastVisit{{$index}}"
                     openlmis-message="label.not.recorded"></label>
            </div>
          </div>
          <div class="form-row clearfix">
            <div class="form-cell">
              <label class="form-questions" openlmis-message="label.number.high.alarms"></label>
            <span class="position-relative">
              <input name="highAlarmEvent{{$index}}" type="number" min="0" max="999" step="1"
                     ng-model="refrigeratorReading.highAlarmEvents.value" numeric-validator="positiveInteger,3"
                     error-holder="highAlarmError{{$index}}" class="right-justified" ng-trim="false"/>
              <span id="highAlarmError{{$index}}" class="rnr-form-error" openlmis-message="error.number.only"
                    style="display: none"></span>
            </span>
              <input id="highAlarmEvent{{$index}}" type="checkbox"
                     ng-model="refrigeratorReading.highAlarmEvents.notRecorded"
                     not-recorded/>
              <label class="checkbox-label" for="highAlarmEvent{{$index}}"
                     openlmis-message="label.not.recorded"></label>

            </div>
          </div>
          <div class="form-row clearfix">
            <div class="form-cell">
              <label openlmis-message="label.number.low.alarms"></label>
            <span class="position-relative">
              <input type="number" min="0" max="999" step="1" name="lowAlarmEvent{{$index}}"
                     ng-model="refrigeratorReading.lowAlarmEvents.value"
                     numeric-validator="positiveInteger,3" ng-trim="false" error-holder="lowAlarmError{{$index}}"
                     class="right-justified"/>
              <span id="lowAlarmError{{$index}}" class="rnr-form-error" openlmis-message="error.number.only"
                    style="display: none"></span>
            </span>

              <input id="lowAlarmEvent{{$index}}" type="checkbox"
                     ng-model="refrigeratorReading.lowAlarmEvents.notRecorded"
                     not-recorded/>
              <label class="checkbox-label" for="lowAlarmEvent{{$index}}"
                     openlmis-message="label.not.recorded"></label>
            </div>
          </div>
        </div>
        <div class="form-group">
          <div class="form-row clearfix">
            <div class="form-cell">
              <label openlmis-message="label.refrigerator.working.correctly"></label>

              <input type="radio" id="functioningCorrectlyYes{{ $index }}"
                     name="functioningCorrectly{{$index}}"
                     value="Y"
                     ng-model="refrigeratorReading.functioningCorrectly.value"/>
              <label for="functioningCorrectlyYes{{ $index }}" class="radio-label"
                     openlmis-message="label.yes"></label>

              <input type="radio" id="functioningCorrectlyNo{{ $index }}"
                     name="functioningCorrectly{{$index}}"
                     value="N" ng-change="showProblemsDiv('functioningCorrectlyNo' + $index)"
                     ng-model="refrigeratorReading.functioningCorrectly.value"/>
              <label class="radio-label" for="functioningCorrectlyNo{{ $index }}"
                     openlmis-message="label.no"></label>

              <input type="radio" id="functioningCorrectlyDontKnow{{ $index }}"
                     name="functioningCorrectly{{$index}}"
                     value="D"
                     ng-model="refrigeratorReading.functioningCorrectly.value"/>
              <label class="radio-label" for="functioningCorrectlyDontKnow{{ $index }}"
                     openlmis-message="label.dont.know"></label>

              <input id="functioningCorrectly{{$index}}" type="checkbox"
                     ng-model="refrigeratorReading.functioningCorrectly.notRecorded" not-recorded/>
              <label class="checkbox-label" for="functioningCorrectly{{$index}}"
                     openlmis-message="label.not.recorded"></label>

              <div class="form-group problem-form"
                   ng-show="refrigeratorReading.functioningCorrectly.value === 'N'">
                <div class="form-row clearfix">
                  <label openlmis-message="label.what.problems"></label>
                </div>
                <div class="form-row clearfix">
                  <input id="operatorError{{ $index }}" type="checkbox"
                         ng-model="refrigeratorReading.problems.operatorError"/>
                  <label class="checkbox-label" for="operatorError{{ $index }}"
                         openlmis-message="label.operator.error"></label>
                </div>
                <div class="form-row clearfix">
                  <input id="egpFault{{ $index }}" type="checkbox"
                         ng-model="refrigeratorReading.problems.egpFault"/>
                  <label class="checkbox-label" for="egpFault{{ $index }}"
                         openlmis-message="label.egp.fault"></label>
                </div>
                <div class="form-row clearfix">
                  <input id="burnerProblem{{ $index }}" type="checkbox"
                         ng-model="refrigeratorReading.problems.burnerProblem"/>
                  <label class="checkbox-label" for="burnerProblem{{ $index }}"
                         openlmis-message="label.burner.problem"></label>
                </div>
                <div class="form-row clearfix">
                  <input id="thermostatSetting{{ $index }}" type="checkbox"
                         ng-model="refrigeratorReading.problems.thermostatSetting"/>
                  <label class="checkbox-label" for="thermostatSetting{{ $index }}"
                         openlmis-message="label.thermostat.setting"></label>
                </div>
                <div class="form-row clearfix">
                  <input id="gasLeakage{{ $index }}" type="checkbox"
                         ng-model="refrigeratorReading.problems.gasLeakage"/>
                  <label class="checkbox-label" for="gasLeakage{{ $index }}"
                         openlmis-message="label.gas.problem"></label>
                </div>
                <div class="form-row clearfix">
                  <input id="other{{ $index }}" type="checkbox"
                         ng-click="refrigeratorReading.problems.otherProblemExplanation = refrigeratorReading.problems.other ? refrigeratorReading.problems.otherProblemExplanation : undefined"
                         ng-model="refrigeratorReading.problems.other"/>
                  <label class="checkbox-label" for="other{{ $index }}"
                         openlmis-message="label.other"></label>
                </div>
                <div class="form-row clearfix">
                  <textarea id="otherTextbox{{ $index }}" ng-show="refrigeratorReading.problems.other"
                            ng-model="refrigeratorReading.problems.otherProblemExplanation"
                            maxlength="255"></textarea>
                </div>
              </div>
            </div>
          </div>
          <div class="form-row clearfix">
            <div class="form-cell" id="notesCell">
              <label openlmis-message="label.notes"></label>
              <textarea id="notes{{ $index }}" ng-model="refrigeratorReading.notes"
                        maxlength="255"></textarea>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="row-fluid">
    <div class="span1"></div>
    <div class="span2">
      <a href="" id="refrigeratorReadingDone" class="btn btn-small btn-primary"
         ng-click="edit[refrigeratorReading.refrigerator.serialNumber] = false;"
         openlmis-message="button.done"></a>
    </div>
  </div>
</div>
</form>
